package com.j2ee.struts.action;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class ServletApiAction extends ActionSupport{
	
	/**
	 * 通过SerlvetActionContext类访问ServletAPI
	 */
	@Override
	public String execute() throws Exception {
		HttpServletRequest request = ServletActionContext.getRequest() ;
		String contextPath = request.getContextPath() ;
		String characterEncoding = request.getCharacterEncoding() ;
		String servletPath = request.getServletPath() ;
		HttpSession session = request.getSession() ;
		HttpServletResponse response = ServletActionContext.getResponse() ;
		ServletContext servletContext = ServletActionContext.getServletContext() ;
		System.out.println(request);
		System.out.println(contextPath);
		System.out.println(servletPath);
		System.out.println(characterEncoding);
		System.out.println(response);
		System.out.println(session);
		System.out.println(servletContext);
		return SUCCESS ;
	}
	
	

}
